<?php

//好站控制器
class Main extends Controller {

	var $userid;
	
	function Main()
	{
		parent::Controller();	
		$this->load->model("accounts_model", "am");
		$this->load->model("site_model", "sm");
		$this->load->model("classes_model", "cm");
		$this->load->model("forum_model");
		$this->load->model("message_model");
		$this->load->model("comment_model");
		$this->load->model("sitestatis_model", "ssm");
		
		//登陆状态检测
		$this->userid = $this->am->is_logined();
		$this->account = $this->am->get_account();
		//获取用户小站信息
		$this->usersite = $this->sm->get_usersite($this->userid);
	}
	
	//好站默认首页
	function index()
	{
		//输出公共header
		$this->autoload_model->output_header();
		
		//获取新鲜事
		$fresh = $this->autoload_model->get_fresh($this->userid);
		
		//获取严选社区文章
		$topics = $this->forum_model->recommend_list();
		
		//看看热站
		$kansites = $this->sm->kan_site();
		
		//推荐热站
		$recommendsites = $this->sm->recommend_site();
		
		//每日一站
		$bestrecommend = $this->sm->get_bestrecommend();
		
		//获取关注数量
		$myfuns = $this->ssm->get_userfuns($this->userid);
		
		//新邮件
		if ($this->userid > 0) {
			$viewdata["mymessages"] = $this->message_model->new_messages($this->userid);
			$viewdata["mynotices"] = $this->message_model->new_notices($this->userid);
			$viewdata["newcomment"] = $this->comment_model->has_newcomment($this->userid);
		}
		
		$viewdata["account"] = $this->account;
		$viewdata["usersite"] = $this->usersite;
		$viewdata["kansites"] = $kansites;
		$viewdata["recommendsites"] = $recommendsites;
		$viewdata["bestrecommend"] = $bestrecommend;
		$viewdata["fresh"] = $fresh;
		$viewdata["topics"] = $topics;
		$viewdata["myfuns"] = $myfuns;
		$this->load->view(__CLASS__.'/index', $viewdata);
		
		//输出公共footer
		$this->autoload_model->output_footer();
	}

}

/* End of file */